<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGroupmanagerTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('groupmanager', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('roleId')->unsigned();
            $table->bigInteger('userId')->unsigned();
            $table->bigInteger('groupId')->unsigned();
            $table->engine = 'InnoDB';
        });

        Schema::table('groupmanager',function (Blueprint $table){
            $table->foreign('userId')->on('users')->references('id');
            $table->foreign('roleId')->on('group')->references('id');
            $table->foreign('groupId')->on('group')->references('id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('groupmanager');
    }
}
